package model.service;

import java.sql.Timestamp;

public class ServiceRequest {
	
	public static final String REGITERED = "registreeritud";
	private Customer customer;
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	private int customerFk;
	private Timestamp created;
	private Employee createdBy;
	public Employee getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(Employee createdBy) {
		this.createdBy = createdBy;
	}

	private String customerDescription;
	private String employeeDescription;
	private int serviceRequest;
	private ServiceRequestStatusType serviceRequestStatusType;
	
	private ServiceOrder serviceOrder;
	
	public ServiceRequest(int service_request) {
		this.serviceRequest = service_request;
	}
	
	public ServiceRequest() {
		// TODO Auto-generated constructor stub
	}

	public String getCustomerDescription() {
		return customerDescription;
	}

	public String getEmployeeDescription() {
		return employeeDescription;
	}
	public Timestamp getCreated() {
		return created;
	}
	public String getHtmlTableRow() {
		String html = new String();
		html = html.concat("<td>");
		html = html.concat(createdBy.getPerson().getFirstName()+" "+createdBy.getPerson().getLastName());
		html = html.concat("&nbsp;</td>");
		html = html.concat("<td>");
		html = html.concat(created.toString());
		html = html.concat("&nbsp;</td>");
		html = html.concat("<td>");
		html = html.concat(getCustomerName());
		html = html.concat("&nbsp;</td>");
		html = html.concat("<td>");
		html = html.concat(customerDescription);
		html = html.concat("&nbsp;</td>");
		html = html.concat("<td>");
		html = html.concat(employeeDescription);
		html = html.concat("&nbsp;</td>");
		html = html.concat("<td>");
		html = html.concat(serviceRequestStatusType.getTypeName());
		html = html.concat("&nbsp;</td>");
		return html;
		
	}

	public static String getHtmlTableHeader() {
		String html = new String();
		html = html.concat("<th>");
		html = html.concat("Looja");
		html = html.concat("</th>");
		html = html.concat("<th>");
		html = html.concat("Loodud");
		html = html.concat("</th>");
		html = html.concat("<th>");
		html = html.concat("Klient");
		html = html.concat("</th>");
		html = html.concat("<th>");
		html = html.concat("Kliendi kirjeldus");
		html = html.concat("</th>");
		html = html.concat("<th>");
		html = html.concat("Töötaja kirjeldus");
		html = html.concat("</th>");
		html = html.concat("<th>");
		html = html.concat("Seisund");
		html = html.concat("</th>");
		return html;
	}

	public void setCreated(Timestamp timestamp) {
		this.created = timestamp;
		
	}

	public void setCustomerDescription(String string) {
		this.customerDescription = string;
		
	}

	public void setEmployeeDescription(String string) {
		this.employeeDescription = string;
		
	}
	public void setRequest(int request) {
		this.serviceRequest = request;
	}

	public int getRequest() {
		return serviceRequest;
	}
	public String getCustomerName() {
		String name = new String();
		if(customer.getPerson() != null)
			name = name.concat(customer.getPerson().getFirstName()+" "+customer.getPerson().getLastName());
		else if(customer.getEnterprise() != null)
			name = name.concat(customer.getEnterprise().getName());
		return name;
	}
	public void setCustomerFk(int customerFk) {
		this.customerFk = customerFk;
	}

	public int getCustomerFk() {
		return customerFk;
	}

	public void setServiceRequestStatusType(ServiceRequestStatusType serviceRequestStatusType) {
		this.serviceRequestStatusType = serviceRequestStatusType;
	}

	public ServiceRequestStatusType getServiceRequestStatusType() {
		return serviceRequestStatusType;
	}

	/**
	 * @return the serviceOrder
	 */
	public ServiceOrder getServiceOrder() {
		return serviceOrder;
	}

	/**
	 * @param serviceOrder the serviceOrder to set
	 */
	public void setServiceOrder(ServiceOrder serviceOrder) {
		this.serviceOrder = serviceOrder;
	}
}
